package lianxi;

import java.util.Scanner;

public class Demo5 {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);//构建输入对象
        System.out.print("请输入小时：");
        int hour = input.nextInt();//获取小时
        System.out.print("请输入分钟：");
        int minute = input.nextInt();//获取分钟
        System.out.print("请输入秒：");
        int second = input.nextInt();//获取秒钟

        //计算总秒数
        int SumSecond = hour * 60 * 60 + minute * 60 + second;

        if (SumSecond > 86400 || SumSecond < 0) {
            System.err.println("输入错误");
            return;
        } else {//+1秒
            SumSecond = SumSecond + 1;
            System.out.println("SumSecond = " + SumSecond);
        }
        if (SumSecond >= 86400) {
            SumSecond = SumSecond - 86400;
        }

        //计算
        hour = SumSecond / 60 / 60;//计算小时
        minute = (SumSecond - hour * 60 * 60) / 60;//计算分钟
        second = SumSecond - hour * 3600 - minute * 60;//计算秒钟

        //格式处理
        String hour1 = "" + hour;
        String minute1 = "" + minute;
        String second1 = "" + second;
        if (hour < 10) {
            hour1 = "0" + hour;
        }
        if (minute < 10) {
            minute1 = "0" + minute;
        }
        if (second < 10) {
            second1 = "0" + second;
        }
        System.out.println("下一秒的时间为：");//下一行输出
        System.out.println(hour1 + ":" + minute1 + ":" + second1);


    }
}
